package com.xiaobaibai.controller;

import com.xiaobaibai.entity.Announcement;
import com.xiaobaibai.response.ResponseFormat;
import com.xiaobaibai.service.IAnnouncementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "公告数据接口")
@RequestMapping("/announcement")
@CrossOrigin
public class AnnouncementController {

    @Autowired
    private IAnnouncementService announcementService;

    @GetMapping("/list")
    @ApiOperation("获取公告集合")
    public ResponseFormat getAnnouncementTitle(){
        List<Announcement> list = announcementService.getAnnouncementListNoContent();
        return ResponseFormat.ok("获取公告集合成功",list);
    }

    @GetMapping("/item/{id}")
    @ApiOperation("获取单个公告的详细信息")
    public ResponseFormat getAnnouncementItem(@PathVariable(value = "id")Integer id){
        Announcement item = announcementService.getAnnouncementItem(id);
        return ResponseFormat.ok("获取公告数据成功",item);
    }

}
